<?php
/**
 * Created by PhpStorm.
 * User: wliu
 * Date: 14-3-29
 * Time: 下午9:58
 */

class CommonUtils {

    public static function getLocal() {
        $local = Yii::app()->session->get(_LOCAL_FLAG);
        if (!empty($local)) return $local;
        return _LOCAL_ZN;
    }

    public static function getUserId() {
        $user = Yii::app()->session->get(_SESSIONID);
        if (!empty($user)) {
            return (string)$user['_id'];
        }
        return "";
    }

    public static function getMillisecond(){
        list($s1,$s2)=explode(' ',microtime());
        return (float)sprintf('%.0f',(floatval($s1)+floatval($s2))*1000);
    }

    public static function getUser() {
        $user = Yii::app()->session->get(_SESSIONID);
        if (!empty($user)) {
            return $user;
        }
        return null;
    }

    public static function getSales() {
        $sales = Yii::app()->session->get(_SESSIONID_SALES);
        if(!empty($sales)){
            return $sales;
        }
        return null;
    }

    public static function getSalesId() {
        $sales = Yii::app()->session->get(_SESSIONID_SALES);
        if(!empty($sales)){
            return (string)$sales['_id'];
        }
        return "";
    }
} 